
// program:		replication_Zittel_Nyhuis_Baumann_geographic_representation.do
// paper:		Geographic Representation in Party-Dominated Legislatures: 
//				A Quantitative Text Analysis of Parliamentary Questions in the German Bundestag
//				Legislative Studies Quarterly
// authors:		Thomas Zittel, Dominic Nyhuis & Markus Baumann
// date:		February 2019

// Preparation
clear all
macro drop _all

ssc install estout // if not yet installed
ssc install blindschemes // if not yet installed
set scheme plotplain

global path = "[PATH]"
* ... should refer to the folder where the .dta file is saved.

use "$path\replication_data_Zittel_Nyhuis_Baumann_geographic_representation.dta", clear


// DESCRIPTIVE STATISTICS
// Number of questions with geographic reference
tab quest_n_geo_bkg
sum(quest_n_geo_bkg)
display r(sum)

// Number of questions
tab quest_n
sum(quest_n)
display r(sum)

// Number of questions with geographic reference if any questions
sum quest_n_geo_bkg if quest_n > 0, detail

// Number of questions with geographic reference if any questions with
// geographic reference
sum quest_n_geo_bkg if quest_n_geo_bkg > 0, detail

sum quest_n_geo_bkg, detail
sum quest_writt_n_geo_bkg, detail
sum quest_oral_n_geo_bkg, detail

// TABLE 2:
eststo m1: nbreg quest_n_geo_bkg volat_t1 local_bio local_pol i.wkmandat##c.C_marginality_abs opposition ///
		seniority_log east		
esttab m1, abs b(3) se(3) ///
	star(* 0.10 ** 0.05 *** 0.01) aic	
	
// FIGURE 1:
eststo m1_plot: nbreg quest_n_geo_bkg east seniority_log opposition i.wkmandat##c.C_marginality_abs local_pol local_bio volat_t1   
// The model is identical to m1, but reorders the IVs for plotting purposes
// Conditional marginal effect (left panel) 		
margins, dydx(*) atmeans level(95)
marginsplot, recast(scatter) horizontal ///
			xline(0, lp(shortdash)lwidth(vthin)lcolor(black)) xscale(range(-5.0 +5.0)) ///
			xlabel(-5.0(1)+5.0,) level(95)	///		
			ylabel(1 "Eastern Germany"  2 "Seniority (log)" 3 "Opposition"  4 "Nominal mandate" ///
			5 "Marginality" 6 "Pol Localness" 7 "Bio Localness"  8 "Volatility" ) 	
		
// Predicted probabilities for different levels of volatility (right panel)
margins, at(volat_t1=(0(1)24) opposition=(0 1)) atmeans
marginsplot, xscale(range(2 +24)) xlabel(0(2)24) yscale(range(0 30)) ylabel(0(5)30) ///
	recast(line) recastci(rline)  level(95) plot1opts(lpattern(solid)) plot2opts(lpattern(dash_dot)) ///
	ci1opts(lpattern(solid) lcolor(gs9)lwidth(vthin)) ci2opts(lpattern(solid)lcolor(gs9)lwidth(vthin)) ///
	legend(order(3 "Government" 4 "Opposition") pos(6) rows(1) )	
	
// TABLE 3 (models 2 and 3)
// Model 2 (written questions)
eststo m2: nbreg quest_writt_n_geo_bkg volat_t1 local_bio local_pol i.wkmandat##c.C_marginality_abs opposition ///
	seniority_log east
	
// Model 3 (oral questions)
eststo m3: nbreg quest_oral_n_geo_bkg volat_t1 local_bio local_pol i.wkmandat##c.C_marginality_abs opposition ///
	seniority_log east
	
esttab m2 m3 , ///
	abs b(3) se(3) ///
	star(* 0.10 ** 0.05 *** 0.01) aic ///
	mtitles( "Model 2" "Model 3")
